﻿//===============================================================================
// Microsoft Innovation Centre - Western Europe
// Copyright (c) 2008 Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.ComponentModel;
using System.Xml.Serialization;
using Microsoft.WVB.Silverlight.Infrastructure;

namespace Microsoft.WVB.Framework
{
    [XmlRoot(ElementName = "Profile", IsNullable = false, Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
    public class ProfileInfo : IProfileInfo, INotifyPropertyChanged
    {
        public ProfileInfo(string username)
            : this()
        {
            this._username = username;
        }

        public ProfileInfo()
        {
            this._username = string.Empty;
            this._Level = ProfileLevel.Anonymous;
        }

        [XmlElement(ElementName = "level", IsNullable = false, Type = typeof(ProfileLevel), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public virtual ProfileLevel Level
        {
            get
            {
                return this._Level;
            }
            set
            {
                this._Level = value;
                OnPropertyChanged(this.GetPropertySymbol(o => o.Level));
            }
        }
        private ProfileLevel _Level;

        [XmlElement(ElementName = "gender", IsNullable = false, Type = typeof(Gender), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public virtual Gender Gender
        {
            get
            {
                return this._Gender;
            }
            set
            {
                this._Gender = value;
                OnPropertyChanged(this.GetPropertySymbol(o => o.Gender));
            }
        }
        private Gender _Gender;

        [XmlElement(ElementName = "firstName", IsNullable = false, Type = typeof(string), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public String FirstName
        {
            get { return _FirstName; }
            set { _FirstName = value; OnPropertyChanged(this.GetPropertySymbol(o => o.FirstName)); }
        }
        private String _FirstName;

        [XmlElement(ElementName = "lastName", IsNullable = false, Type = typeof(string), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public String LastName
        {
            get { return _LastName; }
            set { _LastName = value; OnPropertyChanged(this.GetPropertySymbol(o => o.LastName)); }
        }
        private String _LastName;

        [XmlElement(ElementName = "birthDate", IsNullable = true, Type = typeof(DateTime?), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public DateTime? BirthDate
        {
            get { return _BirthDate; }
            set { _BirthDate = value; OnPropertyChanged(this.GetPropertySymbol(o => o.BirthDate)); }
        }
        private DateTime? _BirthDate;

        [XmlElement(ElementName = "zipCode", IsNullable = true, Type = typeof(int?), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public int? ZipCode
        {
            get { return _ZipCode; }
            set { _ZipCode = value; OnPropertyChanged(this.GetPropertySymbol(o => o.ZipCode)); }
        }
        private int? _ZipCode;

        [XmlElement(ElementName = "country", IsNullable = false, Type = typeof(string), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public String Country
        {
            get { return _Country; }
            set { _Country = value; OnPropertyChanged(this.GetPropertySymbol(o => o.Country)); }
        }
        private String _Country;

        [XmlElement(ElementName = "jobTitle", IsNullable = false, Type = typeof(string), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public String JobTitle
        {
            get { return _JobTitle; }
            set { _JobTitle = value; OnPropertyChanged(this.GetPropertySymbol(o => o.JobTitle)); }
        }
        private String _JobTitle;

        [XmlElement(ElementName = "industry", IsNullable = false, Type = typeof(string), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public String Industry
        {
            get { return _Industry; }
            set { _Industry = value; OnPropertyChanged(this.GetPropertySymbol(o => o.Industry)); }
        }
        private String _Industry;

        [XmlElement(ElementName = "income", IsNullable = true, Type = typeof(double?), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public double? Income
        {
            get { return _Income; }
            set { _Income = value; OnPropertyChanged(this.GetPropertySymbol(o => o.Income)); }
        }
        private double? _Income;

        [XmlElement(ElementName = "companySize", IsNullable = true, Type = typeof(int?), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public int? CompanySize
        {
            get { return _CompanySize; }
            set { _CompanySize = value; OnPropertyChanged(this.GetPropertySymbol(o => o.CompanySize)); }
        }
        private int? _CompanySize;

        [XmlElement(ElementName = "interests", IsNullable = true, Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public String Interests
        {
            get { return _Interests; }
            set { _Interests = value; OnPropertyChanged(this.GetPropertySymbol(o => o.Interests)); }
        }
        private String _Interests;

        [XmlIgnore()]
        public Boolean IsDirty
        {
            get { return _IsDirty; }
            private set { _IsDirty = value; }
        }
        private Boolean _IsDirty;

        [XmlElement(ElementName = "username", IsNullable = false, Type = typeof(string), Namespace = "http://dpewehq.microsoft.com/2008/06/WVB")]
        public String Username
        {
            get { return _username; }
            set { _username = value; OnPropertyChanged(this.GetPropertySymbol(o => o.Username)); }
        }
        private String _username;

        [field: XmlIgnore]
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                if (!this._IsDirty)
                {
                    lock (this)
                    {
                        this._IsDirty = true;
                    }
                }

                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }
    }

    [XmlRoot()]
    public enum ProfileLevel
    {
        [XmlEnum("Anonymous")]
        Anonymous,
        [XmlEnum("Registered")]
        Registered,
        [XmlEnum("Subscribed")]
        Subscribed
    }

    public enum Rating
    {
        G,
        PG,
        PG13,
        R,
        NC17
    }

    [XmlRoot()]
    public enum Gender
    {
        [XmlEnum("Male")]
        Male,
        [XmlEnum("Female")]
        Female,
        [XmlEnum("Unspecified")]
        Unspecified
    }
}